<!--
 * @Author: 孙开源 && sunkaiyuan@namenode.cn
 * @Date: 2023-09-16 14:56:34
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-09-24 15:29:23
 * @Description: 
 * 
-->
 
<template>
  <el-dialog v-model="visible" :title="title" :width="1170" destroy-on-close @closed="$emit('closed')" draggable overflow>

    <sc-VxeTable ref="xGrid" :tablecode="'finance_balance_browser'" :gridEvts="gridEvents"
      :url="$API.finance.balance.browser.setAttrib(urlParams)" :params="params" :gridOps="gridOps">
    </sc-VxeTable>
    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
    </template>
  </el-dialog>
  <SaveDialog v-if="isSaveing" ref="saveDialog" @success="isSaveing = false" @closed="isSaveing = false"></SaveDialog>
</template>

<script>
import SaveDialog from "./../voucher/save";
export default {
  emits: ["success", "closed"],
  components: { SaveDialog },

  props: {
    params: { type: Object, default: () => { } },
    title: { type: String, default: "" },
    urlParams: { type: Object, default: () => { } },
  },
  data() {
    return {
      gridEvents: {
        cellDblclick: ({ row }) => {
          this.editVoucher(row);
        },
        edit: (data) => {
          if (typeof data.$grid !== "undefined") {
            data = data.$grid.getCheckboxRecords()[0];
          }
          this.editVoucher(data);
        },
      },
      rules: {},
      visible: false,
      isSaveing: false,
      gridOps: {
        height: 500,
      },
    };
  },
  mounted() {

  },
  methods: {
    editVoucher(data) {
      this.isSaveing = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.setData(data);
        this.$refs.saveDialog.open("edit");
      });
    },

    //显示
    open() {
      this.visible = true;
      return this;
    },

    async getItems(id) {
      var res = await this.$API.finance.voucher.info.get({
        filter: [{ id: id }],
      });
      if (res.code == 200) {
        this.form = res.data
      }
    },

  },
};
</script>
<style></style>
